package com.xiaohudie.JUC;

/**
 * @Author xiao hu die
 * @Date 2022/1/15 21:32
 * @Version 1.0
 */

import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors;

/**演示线程池*/
public class Thread14 {
    public static void main(String[] args) {
          /**一池2线程*/
        //ExecutorService executorService = Executors.newFixedThreadPool(2);
        /**一池一线程*/
     //   ExecutorService executorService = Executors.newSingleThreadExecutor();
        /**一池可以扩容的线程*/
        ExecutorService executorService = Executors.newCachedThreadPool();
        for (int i = 0; i <= 100; i++) {
            executorService.execute(()->{
                System.out.println(Thread.currentThread().getName()+"正在处理业务");
            });
        }
        executorService.shutdown();
    }
}
                     